package page;

import common.Object;
import common.User;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;

public class MyPostPage {

    private EdgeDriver edgeDriver = Object.getEdgeDriver();
    private final String Frontrurl = "http://82.156.186.83:8080/index.html";
    private LoginPage loginPage = new LoginPage();
    /**
     * 1.进入首页，调用登录函数，用户登录user  123zz
     * 2.用户个人头像，获取“我的帖子”元素
     * 3.点击“我的帖子”，获取这一界面特殊元素
     */
    public void displayMyPostPage (User user) throws InterruptedException {
        loginPage.login(user);
        WebElement myButton = edgeDriver.findElement(By.cssSelector("#index_nav_avatar"));
        Thread.sleep(2000);
        myButton.click();

        WebElement myPostPageButton = edgeDriver.findElement(By.cssSelector("#index_user_profile"));
        Thread.sleep(2000);
        myPostPageButton.click();

        WebElement test = edgeDriver.findElement(By.xpath("//*[@id=\"bit-forum-content\"]"));
        Thread.sleep(2000);
        String str = test.getText();
        System.out.println(str);
        if (str.contains("个人介绍")){
            System.out.println("打开我的帖子成功");
        }else {
            System.out.println("打开我的帖子失败");
        }

    }
    public void close (){
        edgeDriver.close();
    }

}
